package com.example.day18_7_18_1.avtivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.bumptech.glide.Glide;
import com.example.day18_7_18_1.R;
import com.example.day18_7_18_1.adapter.InfoVpAdapter;
import com.example.day18_7_18_1.bean.Bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageActivity extends AppCompatActivity {

    private ViewPager mVp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_page);
        initView();
    }

    private void initView() {
        mVp = (ViewPager) findViewById(R.id.vp);
        List<View> list = new ArrayList<>();
        Intent intent = getIntent();
        Bean data = (Bean) intent.getSerializableExtra("data");
        for (Bean.DataBean.DatasBean datasBean : data.getData().getDatas()) {
            View inflate = LayoutInflater.from(this).inflate(R.layout.layout_pager, null);
            ImageView img_vp = inflate.findViewById(R.id.img_vp);
            Glide.with(this).load(datasBean.getEnvelopePic()).into(img_vp);
            list.add(inflate);
        }
        InfoVpAdapter infoVpAdapter = new InfoVpAdapter(list);
        mVp.setAdapter(infoVpAdapter);
    }
}
